home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_qt.idb / usr / freeware / include / qtabbar.h.z / qtabbar.h
C/C++ Source or Header  |  2001-04-12  |  5KB  |  168 lines

  1. /****************************************************************************
  2. ** $Id: qt/src/widgets/qtabbar.h   2.3.0   edited 2001-01-26 $
  3. **
  4. ** Definition of QTab and QTabBar classes
  5. **
  6. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  7. **
  8. ** This file is part of the widgets module of the Qt GUI Toolkit.
  9. **
  10. ** This file may be distributed under the terms of the Q Public License
  11. ** as defined by Trolltech AS of Norway and appearing in the file
  12. ** LICENSE.QPL included in the packaging of this file.
  13. **
  14. ** This file may be distributed and/or modified under the terms of the
  15. ** GNU General Public License version 2 as published by the Free Software
  16. ** Foundation and appearing in the file LICENSE.GPL included in the
  17. ** packaging of this file.
  18. **
  19. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  20. ** licenses may use this file in accordance with the Qt Commercial License
  21. ** Agreement provided with the Software.
  22. **
  23. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  24. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  25. **
  26. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  27. **   information about Qt Commercial License Agreements.
  28. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  29. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  30. **
  31. ** Contact info@trolltech.com if any conditions of this licensing are
  32. ** not clear to you.
  33. **
  34. **********************************************************************/
  35.  
  36. #ifndef QTABBAR_H
  37. #define QTABBAR_H
  38.  
  39. #ifndef QT_H
  40. #include "qwidget.h"
  41. #include "qpainter.h"
  42. #include "qlist.h"
  43. #include "qiconset.h"
  44. #endif // QT_H
  45.  
  46. #ifndef QT_NO_TABBAR
  47.  
  48. class Q_EXPORT QTab
  49. {
  50. public:
  51.     QTab(): enabled( TRUE ), id( 0 ), iconset( 0 ) {}
  52.     virtual ~QTab();
  53.     QTab( const QString& text )
  54.     : label( text ), enabled( TRUE ), id( 0 ), iconset( 0 ) {}
  55.     QTab( const QIconSet& icon, const QString& text = QString::null )
  56.     : label( text ), enabled( TRUE ), id( 0 ), iconset( new QIconSet(icon) ) {}
  57. #if 1
  58.     void setText( const QString& text) { label = text; }
  59.     QString text() const { return label; }
  60.     void setIconSet( const QIconSet& icon ) { iconset = new QIconSet( icon ); }
  61.     QIconSet* iconSet() const { return iconset; }
  62.     void setRect( const QRect& rect ) { r = rect; }
  63.     QRect rect() const { return r; }
  64.     void setEnabled( bool enable ) { enabled = enable; }
  65.     bool isEnabled() const { return enabled; }
  66.     void setIdentifier( int i ) { id = i; }
  67.     int identitifer() const { return id; }
  68. #endif
  69. // private: (public for compatibility, ### change 3.0)
  70.     QString label;
  71.     QRect r;    // the bounding rectangle of this - may overlap with others
  72.     bool enabled;
  73.     int id;
  74.     QIconSet* iconset;     // optional iconset
  75. };
  76.  
  77.  
  78. struct QTabPrivate;
  79.  
  80.  
  81. class Q_EXPORT QTabBar: public QWidget
  82. {
  83.     Q_OBJECT
  84.     Q_ENUMS( Shape )
  85.     Q_PROPERTY( Shape shape READ shape WRITE setShape )
  86.     Q_PROPERTY( int currentTab READ currentTab WRITE setCurrentTab )
  87.     Q_PROPERTY( int count READ count )
  88.     Q_PROPERTY( int keyboardFocusTab READ keyboardFocusTab )
  89.  
  90. public:
  91.     QTabBar( QWidget *parent = 0, const char *name = 0 );
  92.    ~QTabBar();
  93.  
  94.     enum Shape { RoundedAbove, RoundedBelow,
  95.          TriangularAbove, TriangularBelow };
  96.  
  97.     Shape shape() const;
  98.     virtual void setShape( Shape );
  99.  
  100.     void show();
  101.  
  102.     virtual int addTab( QTab * );
  103.     virtual int insertTab( QTab *, int index = -1 );
  104.     virtual void removeTab( QTab * );
  105.  
  106.     virtual void setTabEnabled( int, bool );
  107.     bool isTabEnabled( int ) const;
  108.  
  109.     QSize sizeHint() const;
  110.     QSize minimumSizeHint() const;
  111.     QSizePolicy sizePolicy() const;
  112.  
  113.     int currentTab() const;
  114.     int keyboardFocusTab() const;
  115.  
  116.     QTab * tab( int );
  117.     int count() const;
  118.  
  119.     virtual void layoutTabs();
  120.  
  121. public slots:
  122.     virtual void setCurrentTab( int );
  123.     virtual void setCurrentTab( QTab * );
  124.  
  125. signals:
  126.     void  selected( int );
  127.  
  128. protected:
  129.     virtual void paint( QPainter *, QTab *, bool ) const; // ### not const
  130.     virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;
  131.  
  132.     void focusInEvent( QFocusEvent *e );
  133.     void focusOutEvent( QFocusEvent *e );
  134.  
  135.     virtual QTab * selectTab( const QPoint & p ) const;
  136.     void updateMask();
  137.  
  138.     void resizeEvent( QResizeEvent * );
  139.     void paintEvent( QPaintEvent * );
  140.     void mousePressEvent ( QMouseEvent * );
  141.     void mouseReleaseEvent ( QMouseEvent * );
  142.     void keyPressEvent( QKeyEvent * );
  143.     void styleChange( QStyle& );
  144.  
  145.     QList<QTab> * tabList();
  146.  
  147. private slots:
  148.     void scrollTabs();
  149.  
  150. private:
  151.     QList<QTab> * l;
  152.     QList<QTab> * lstatic;
  153.     void makeVisible( QTab* t  );
  154.     void updateArrowButtons();
  155.     QTabPrivate * d;
  156.  
  157. private:    // Disabled copy constructor and operator=
  158. #if defined(Q_DISABLE_COPY)
  159.     QTabBar( const QTabBar & );
  160.     QTabBar& operator=( const QTabBar & );
  161. #endif
  162. };
  163.  
  164.  
  165. #endif // QT_NO_TABBAR
  166.  
  167. #endif // QTABBAR_H
  168.